# -*- coding: utf-8 -*-

import os,time
from MsgProcess import MsgProcess, MsgType

        
class WeatherForecast(MsgProcess):
    def Text(self, message):  

        data=message["Data"][:-4]

        if "关闭" in data or "取消" in data:
            data = {'type': 'nav', 'data': {"event": "close"}}
            self.send(MsgType.Text, Receiver='Screen',Data=data)  # 取消显示
            self.Stop() 
            return

        if data:
            nav_json = {"event": "open", "size": {"width": 346, "height": 390}, "url": "plugin/WeatherForecast/weatherForecast.html?qr=" + data}
            data = {'type': 'nav', 'data': nav_json}
            self.send(MsgType.Text, Receiver='Screen', Data=data)

        else:
            self.say("天气预报失败,请说出正确城市名,你可以说北京天气预报")
            
        self.Stop()  

